README File for replication of all figures and tables reported in Lee, Byungkyu. "Close Relationships in Close Elections" _Social Forces_, 2020, forthcoming. 

Date : 09/05/2020
Written by : Byungkyu Lee (bl11@indiana.edu)

This file contains Stata Do files and R codes to reproduce all figures and tables appeared in the main manuscript as well as the online Appendix. 

## Data
`data` folder contains the following directories:

1. `rawdata` folder includes all four ego-centric network survey data from the National Election Studies and Time Sharing Experiment for Social Sciences, as well as historical state-level presidential election data. In the 2016 TESS data, some people type multiple names in one box, which underestimated the true network size. I fixed this issue manually revisiting `Q6_name` variable in `tess_all.dta` data, and include `tess_2016_name_fix.dta` that fixed the problem. To get the raw data file, please visit the following websites to download each data set.
	* CNES 1992 (`CNES_1.dta`): https://www.icpsr.umich.edu/web/ICPSR/studies/6541/
	* ANES 2000 (`anes2000TS.dta`): https://electionstudies.org/data-center/2000-time-series-study/
	* ANES 2008-09 Internet Panel Study (`anes2008_2009panel_dataset.dta`): https://electionstudies.org/data-center/2008-2009-panel-study/
	* TESS 2016 (`tess_all.dta`) : https://osf.io/6esdw/
	* State-level close election data (`state_election_all.csv`) : You can obtain the raw data from https://uselectionatlas.org/, and I initiallyl downloaded the rawdata from Columbia University Library in May 30, 2017. You can download the same data from here : https://docs.google.com/spreadsheets/d/1D-edaVHTnZNhVU840EPUhz3Cgd7m39Urx7HM8Pq6Pus/edit#gid=29622862 

2. `rawdata_safegraph` folder is empty since the data is too big. See this for downloading data: https://www.anderson.ucla.edu/faculty_pages/keith.chen/papers/Science_2018_ReadMe.pdf

3. `rawdata_political_ad` folder is empty since the data is not publicly available. Please consult the following webpages to get access to the data.
	* 2000, 2008 elections : `Political Advertising in 2000.dta`, `WiscAds2008_GSHData.dta` and `WiscAds2008_Presidential.dta` from https://elections.wisc.edu/wisconsin-advertising-project/ 
	* 2016 election : `wmp-senate-2016-v1.0.dta`, `wmp-house-2016-v1.0.dta`, and `wmp-gov-2016-v1.0.dta` from https://mediaproject.wesleyan.edu/

4. Once you have all the raw data into this `rawdata` folder, you should be able to reproduce all files in `processed` data folder, which can be used for all other analysis. In `processed` data folder, I include all intermediate files that I generated from these rawdata using `0_data setup_XXXX_.do` and `0_clean_politial_ad_data.R` codes. 

## Code 
Once you have all data in `processed` data folder, you should be able to reproduce all figures/tables by following the steps described by `BG-meta_all.do`. 

## Output
`output` folder contains the final results.

## Program Version Information : 
-- Stata 16 MP version for all analysis.
-- R 4.0.1 for all analysis.

If you have any question on these files or fail to reproduce any of figures or tables, then please direct your correspondence to BK Lee (bklee009@gmail.com). 
